﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Windows.Browser;

namespace jLight
{
    public class jQueryObject : jQueryObjectBase
    {
        /// <summary>
        /// Get the HTML contents of the first element in the set of matched elements.
        /// </summary>
        public string Html
        {
            set { InvokeScriptObject("html", value); }
            get { return InvokeScriptObject<string>("html"); }
        }
        /// <summary>
        /// Get the combined text contents of each element in the set of matched elements, including their descendants.
        /// </summary>
        public string Text
        {
            set { InvokeScriptObject("text", value); }
            get { return InvokeScriptObject<string>("text"); }
        }
        /// <summary>
        /// Get the current vertical position of the scroll bar for the first element in the set of matched elements.
        /// </summary>
        public double ScrollTop
        {
            set { InvokeScriptObject("scrollTop", value); }
            get { return InvokeScriptObject<double>("scrollTop"); }
        }
        /// <summary>
        ///  Get the current horizontal position of the scroll bar for the first element in the set of matched elements.
        /// </summary>
        public double ScrollLeft
        {
            set { InvokeScriptObject("scrollLeft", value); }
            get { return InvokeScriptObject<double>("scrollLeft"); }
        }
        /// <summary>
        ///  Get the current computed height for the first element in the set of matched elements, including padding but not border.
        /// </summary>
        public double InnerHeight
        {
            set { InvokeScriptObject("innerHeight", value); }
            get { return InvokeScriptObject<double>("innerHeight"); }
        }
        /// <summary>
        /// Get the current computed width for the first element in the set of matched elements, including padding but not border.
        /// </summary>
        public double InnerWidth
        {
            set { InvokeScriptObject("innerWidth", value); }
            get { return InvokeScriptObject<double>("innerWidth"); }
        }
        /// <summary>
        /// Get a property by index
        /// </summary>
        public jQueryObject this[int a]
        {
            get { return (ScriptObject)ScriptObject.GetProperty(a); }
        }
        /// <summary>
        /// Get a property by propertyname
        /// </summary>
        public object this[string property]
        {
            get { return ScriptObject.GetProperty(property); }
            set { ScriptObject.SetProperty(property, value); }
        }

        public jQueryObject(ScriptObject scriptObject)
        {
            ScriptObject = scriptObject;
        }

        public new static jQueryObject FromObject(object scriptObject)
        {
              return (ScriptObject)scriptObject;
        }
        public static implicit operator jQueryObject(ScriptObject m)
        {
            return new jQueryObject(m);
        }
        public static implicit operator ScriptObject(jQueryObject m)
        {
            return m.ScriptObject;
        }


        //public void Each(Func<object, object, object> func)
        //{
        //    throw new NotImplementedException();
        //}
    }
}